<%@include file="/header.jsp"%>
<%@ page language="java" contentType="text/html" %>
<script type="text/javascript">
function focusUsername() {
	document.loginForm.username.focus();
}

function checkForm()
{
	var form = document.loginForm;
	
	//username
	if(form.username.value=="" || form.username.value==null)
	{
		alert("Input username");
		form.username.focus();
		return false;
	}
	//password
	else if(form.passwd.value=="" || form.passwd.value==null ) 
	{
		alert("Input password");
		form.passwd.focus();
		return false;
	}
	else { 
		form.submit();
	}
}

</script>

<body onLoad="focusUsername()">

<%
	String username = (String) session.getAttribute("username");
	if(username == null) {
%>
	<h2>Log In</h2>
	<form method = "POST" name="loginForm" action="<%=common.JspUtil.URL_CONTENT_PAGE%>/login/loginProcess.jsp">
		<table>
		<tr><td align="center">Username</td>
		    <td><input type="text" name="username" maxlength="10"></td>
		</tr>
		<tr><td  align="center">Password</td>
		    <td><input type="password" name="passwd" maxlength="10"></td>
		</tr>
		<tr><td colspan="2" align="left"><input type="button" value="Login" onClick="checkForm()"></td>
		</tr>
		</table>	
	</form>
	Don't have an account? Go and <a href="<%=common.JspUtil.URL_CONTENT_PAGE%>/members/addMember.jsp">JoinUs</a>!
<% } else {
%>
	Welcome, <%=username%>!<br>
	<input type="button" value="Logout" onClick="window.location='<%=common.JspUtil.URL_CONTENT_PAGE%>/login/logout.jsp'">
<% } %>
</body>
<%@include file="/footer.jsp"%>